package com.xhji.spider.entity;

import com.xhji.web.mvc.validation.rules.Create;
import com.xhji.web.mvc.validation.rules.Update;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "spiderboot.user")
public class User {
    @Id
    @NotNull(groups = Update.class, message = "id不能为空")
    private Integer id;
    /**
     * 昵称
     */
    private String nick;
    /**
     * 真实姓名
     */
    @NotBlank(groups = Create.class, message = "姓名不能为空！")
    @Column(name = "real_name")
    private String realName;
    /**
     * 性别
     */
    @NotNull(groups = Create.class, message = "性别不能为空！")
    @Column
    private Gender gender;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    public enum Gender {
        /**
         * 男
         */
        MAN,
        /**
         * 女
         */
        WOMAN,
        /**
         * 未知
         */
        UNKNOWN
    }
}